package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.StrategyFavors;
import cn.wolfcode.wolf2w.repository.StrategyFavorsRepository;
import cn.wolfcode.wolf2w.service.IStrategyFavorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StrategyFavorsServiceImpl implements IStrategyFavorsService {
    @Autowired
    private StrategyFavorsRepository strategyFavorsRepository;

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void save(StrategyFavors strategyFavors) {
        strategyFavors.setId(null);
        strategyFavorsRepository.save(strategyFavors);
    }

    @Override
    public void update(StrategyFavors strategyFavors) {
        strategyFavorsRepository.save(strategyFavors);
    }

    @Override
    public void delete(String id) {
        strategyFavorsRepository.deleteById(id);
    }

    @Override
    public StrategyFavors get(String id) {
        return strategyFavorsRepository.findById(id).orElse(null);
    }

    @Override
    public List<StrategyFavors> listAll() {
        return strategyFavorsRepository.findAll();
    }

    @Override
    public StrategyFavors queryByUsid(String uid) {
        return strategyFavorsRepository.findByUsid(uid);
    }
}
